/**
  ******************************************************************************
  * Copyright (C) 2020 - ~, SCUT-RobotLab Development Team
  * @file    sim_interface.cpp
  * @author  Mentos Seetoo
  * @brief   Header file of simulation interface.
  ******************************************************************************
  * @attention
  * 
  * if you had modified this file, please make sure your code does not have any 
  * bugs, update the version Number, write dowm your name and the date.What most
  * important is to make sure the users will have clear an understanding through
  * your new brief.
  ******************************************************************************
  */
#pragma once
/* Includes ------------------------------------------------------------------*/
#include "QuadrupedKernel.h"
#include "sys_thread.h"
#ifdef LOCAL_SIMULATION
#include "Simulation/coppeliaSim-client/CoppeliaSim.h"
#endif

/* Private  ------------------------------------------------------------------*/
enum SimItOP_State
{
    SUCCESS,
    FAILED
};

#ifdef LOCAL_SIMULATION
using SimData = struct _SimData
{
    _simObjectHandle_Type* Joint[4][3];
    _simObjectHandle_Type* Body;
    _simSignalHandle_Type* Gyro[3];
};
#endif
/* Exported ------------------------------------------------------------------*/
/**
   @brief User Interface, 200Hz thread period.
*/
class SimInterface:public CThread
{
public:
    SimInterface(Quadruped::QuadrupedKernel<float> *kernel,std::string thread_name,
                float period, ThreadType type):CThread(period,thread_name,type)
    {
        robot_kernel = kernel;
    }

protected:
    Quadruped::QuadrupedKernel<float> *robot_kernel;
#ifdef LOCAL_SIMULATION
    CoppeliaSim_Client *hClient;
    SimData _sim_data;
#endif
    virtual void _configSimulation() = 0;
    virtual void _sendToSimulation() = 0;
    virtual void _readFromSimulation() = 0;
private:
    void init();
    void task();
    void clean_up(){;}
};

/************************ COPYRIGHT(C) SCUT-ROBOTLAB **************************/